﻿using System;
using System.Data;
using System.Collections.Generic;
using SERP.DAO;
namespace SERP.Controllers{
public class BinaryDataControllerBase : Controller{
	public BinaryDataControllerBase()
		: base()
	{
	}
	private static BinaryDataDAO _Service; 
	public static BinaryDataDAO Service{
		get{
			if(_Service==null)
				_Service = new BinaryDataDAO();
			return _Service;
		}
		set{
			_Service = value;
		}
	}
    //Copy data from data row in grid to object
    public BinaryDataEntity MapDataRowToObject(DataRow row){
		BinaryDataEntity o = new BinaryDataEntity();
		 if(!row.IsNull("Data"))
			o.Data=(Byte[])(row["Data"]);
		 o.FileName=Convert.ToString(row["FileName"]);
		 if(!row.IsNull("BinaryDataId"))
		    o.BinaryDataId=(Int32)(row["BinaryDataId"]);
		 return o;
    }
	//Copy data from object to data row in grid    
    public void MapObjectToDataRow(BinaryDataEntity o,DataRow row){
		row["Data"]=o.Data;
		row["FileName"]=o.FileName;
		row["BinaryDataId"]=o.BinaryDataId;
    }
}
}
